<?php
/*
 * article class
 */
namespace lightblog\home\controller;

use lightblog\engine\controller;
use lightblog\home\model\articleModel;
use lightblog\home\model\commentModel;

class article extends controller {
    function indexAction() {
        $aid = \lightblog::$app->request->parameter->get['id'];

        // 取文章
        $model = new articleModel;
        $article = $model->getArticle($aid);

        // 取文章评论
        $comment_model = new commentModel();
        $comment = $comment_model->getArticleComment($aid);

        $data = array(
            'article' => $article,
            'comment' => $comment,
        );
        return $this->render($data);
    }

    function categoriesAction() {
        $model = new articleModel;
        $category = $model->getCategory();
        return $this->render(array('category' => $category));
    }

    function tagsAction() {
        $model = new articleModel;
        $tags = $model->getTags();
        return $this->render(array('tags' => $tags));
    }
}
